package dfl.bysj.controller;


import dfl.bysj.exception.Assert;
import dfl.bysj.handler.NoAuth;
import dfl.bysj.result.R;
import dfl.bysj.result.ResponseEnum;
import dfl.bysj.service.AcademyService;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author DFL
 * @since 2022-04-26
 */
@RestController
@RequestMapping("/academy")
public class AcademyController {

    AcademyService academyService;


    @Autowired
    public void setAcademyService(AcademyService academyService) {
        this.academyService = academyService;
    }


    @NoAuth
    @GetMapping("/main/academy")
    public R main_academy(String acaId){
        Assert.notNull(acaId, ResponseEnum.ERROR);
        return R.ok().data("academy", academyService.getAcademyById(Integer.parseInt(acaId)));
    }

    @GetMapping("/list")
    public R list(){
        return R.ok().data("list", academyService.getAllAcademy());
    }
}

